#hash数据类型API

import redis
pool=redis.ConnectionPool(host="192.168.100.3",port=6379,decode_responses=True)
client=redis.Redis(connection_pool=pool)
client.flushdb()
#插入
# client.hset("user","username","zhangsan")
# #查询
# print(client.hget("user","username"))
#批量插入
client.hmset("user",{"username":"zhangsan","password":123456})
print(client.hmget("user","username","password"))

#查询某个属性是否存在
print(client.hexists("user","password"))
#获取所有属性名称
print(client.hkeys("user"))
#获取所有属性值
print(client.hvals("user"))

client.hset("user","age",20)
#自增
print(client.hincrby("user","age",5))
#setnx()
client.hsetnx("user","score",100)
print(client.hget("user","score"))











